package com.jeefw.cloud.httpws.ws.jaxrs;

import java.util.List;  
import java.util.Map;  
  
import javax.ws.rs.Consumes;  
import javax.ws.rs.DELETE;  
import javax.ws.rs.FormParam;  
import javax.ws.rs.GET;  
import javax.ws.rs.POST;  
import javax.ws.rs.PUT;  
import javax.ws.rs.Path;  
import javax.ws.rs.PathParam;  
import javax.ws.rs.Produces;  
import javax.ws.rs.QueryParam;  
import javax.ws.rs.core.MediaType;  
  
public interface ProductService {  
  
    @GET  
    @Path("/products")  
    @Produces(MediaType.APPLICATION_JSON)  
    List<Product> retrieveAllProducts();  
    
    @GET  
    @Path("/product/{id}")  
    @Produces(MediaType.APPLICATION_JSON)  
    Product retrieveProductById(@PathParam("id")long id);  
      
    /** 
     * 参数查询 
     * @param name 
     * @return 
     */  
    @GET  
    @Path("/products/name")  
    @Produces(MediaType.APPLICATION_JSON)  
    List<Product> retrieveProductsByName_param(@QueryParam("name")String name);  
      
    /** 
     * 提交表单查询 
     * @param name 
     * @return 
     */  
    @POST  
    @Path("/products/form/name")  
    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)  
    @Produces(MediaType.APPLICATION_JSON)  
    List<Product> retrieveProductsByName_form(@FormParam("name")String name);  
  
      
    @POST  
    @Path("/product")  
    @Consumes(MediaType.APPLICATION_JSON)  
    @Produces(MediaType.APPLICATION_JSON)  
    Product createProduct(Product product);  
      
    @PUT  
    @Path("/product/{id}")  
    @Consumes(MediaType.APPLICATION_JSON)  
    @Produces(MediaType.APPLICATION_JSON)  
    Product updateProductById(@PathParam("id")long id,Map<String,Object> fieldMap);  
      
    @PUT  
    @Path("/product")  
    @Consumes(MediaType.APPLICATION_JSON)  
    @Produces(MediaType.APPLICATION_JSON)  
    Product updateProduct(Product product);  
      
    @DELETE  
    @Path("/product/{id}")  
    @Produces(MediaType.APPLICATION_JSON)  
    Product deleteProductById(@PathParam("id")long id);  
      
    @DELETE  
    @Path("/product")  
    @Produces(MediaType.APPLICATION_JSON)  
    Product deleteProductById_param(@QueryParam("id")long id);  
}  
